CFLAGS=-ggdb -Wall -pedantic
BISON=bison
FLEX=flex
CC=g++
 
parser: parser.o scanner.o driver.o compiler.o executor.o main.o opcodes.o types.o
	$(CC) $(CFLAGS) -o todo scanner.o parser.o driver.o compiler.o executor.o main.o opcodes.o types.o
 
driver.cpp:
	$(CC) $(CFLAGS) -o driver driver.cpp

types.cpp:
	$(CC) $(CFLAGS) -o types.o types.cpp
	
compiler.cpp:
	$(CC) $(CFLAGS) -o compiler.o compiler.cpp
	
main.cpp:
	$(CC) $(CFLAGS) -o main.o main.cpp

executor.cpp:
	$(CC) $(CFLAGS) -o executor.o executor.cpp
		
opcodes.cpp:
	$(CC) $(CFLAGS) -o opcodes.o opcodes.cpp

parser.cpp: parser.y
	$(BISON) -d -oparser.cpp parser.y
 
scanner.cpp: scanner.l
	$(FLEX) -oscanner.cpp scanner.l
	
test:
	$(CC) $(CFLAGS) -otodox todox.cpp testrunner.cpp -lpcrecpp
 
clean:
	rm -f todo scanner.cpp scanner.o parser.cpp parser.o parser.output \
		driver.o parser.hpp stack.hh position.hh location.hh executer.o \
		compiler.o main.o opcodes.o types.o
